<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <h2>总价格：{{totalPrice}}</h2>
</div>
<script src="../vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      books: [
        {id: 110, name: 'xqz', price: 119},
        {id: 111, name: 'xqz', price: 119},
        {id: 112, name: 'xqz', price: 119},
        {id: 113, name: 'xqz', price: 119}
      ]
    },
    computed: {
      totalPrice: function () {
        return this.books.reduce(function (tmp, item, index) {
          if (index === 1) {
            return tmp.price + item.price
          } else {
            return tmp + item.price
          }
        })
      }
    }

  })
</script>
</body>
</html>
